#include <bits/stdc++.h>
using namespace std;

int n, m, cnt, cnt2, num, group, dfn[100001], low[100001], flag[100001], type[100001], idx;
vector<int> edge[100001];
unordered_map<int, int> mp;

void tarjan(int u, int fa)
{
    dfn[u] = low[u] = ++idx;
    int child = 0;
    for (int x : edge[u]) {
        if (!dfn[x]) {
            child++;
            tarjan(x, u);
            low[u] = min(low[u], low[x]);
            if (fa != u && low[x] >= dfn[u] && !flag[u])
                flag[u] = true;
        } else if (x != fa)
            low[u] = min(low[u], dfn[x]);
    }
    if (fa == u && child >= 2 && !flag[u])
        flag[u] = true;
}

void dfs(int x)
{
    type[x] = group;
    cnt2++;
    for (int v : edge[x]) {
        if (type[v] != group && flag[v])
            cnt++, type[v] = group;
        else if (type[v] != group)
            dfs(v);
    }
}

int main()
{
    int op = 0;
    while (true) {
        cin >> n;
        op++;
        if (n == 0)
            break;
        memset(dfn, 0, sizeof dfn), memset(low, 0, sizeof low), memset(low, 0, sizeof low), memset(flag, 0, sizeof flag), memset(type, 0, sizeof type);
        mp.clear();
        for (int i = 1; i <= num; i++)
            edge[i].clear();
        num = 0;
        for (int i = 1; i <= n; i++) {
            int x, y;
            cin >> x >> y;
            if (!mp.count(x))
                mp[x] = ++num;
            if (!mp.count(y))
                mp[y] = ++num;
            edge[mp[x]].push_back(mp[y]);
            edge[mp[y]].push_back(mp[x]);
        }
        tarjan(1, 1);
        long long ans1 = 0, ans2 = 1;
        for (int i = 1; i <= num; i++)
            if (!type[i] && !flag[i]) {
                cnt = cnt2 = 0, group++, dfs(i);
                if (cnt == 0)
                    ans2 *= cnt2 * (cnt2 - 1) / 2, ans1 += 2;
                else if (cnt == 1)
                    ans2 *= cnt2, ans1 += 1;
            }
        cout << "Case " << op << ": " << ans1 << " " << ans2 << endl;
    }
    return 0;
}